<?php

//前台首页
class indexMod extends commonMod
{
    public function __construct()
    {
        parent::__construct();

    }


    //首页
    public function index()
    {

        if($this->config['MOD_TYPE']==1){
        
        $listRows = $this->config['BLOG_PAGE'];
        $url = __APP__ . '/index-{page}.html';
        $page = new Page();
        $cur_page = $page->getCurPage($url);
        $limit_start = ($cur_page - 1) * $listRows;
        $limit = $limit_start . ',' . $listRows;

        $langid=$this->getlangid();
        if(!empty($langid)){
        $langwhere=' AND A.lang='.$langid; //当前语言数据
        }
        $where = 'WHERE A.status=1';
        $sql = "SELECT A.*,B.pid,B.type as ctype,B.name as cname,B.seoname as cseoname,B.pinyin as cpinyin FROM {$this->model->pre}content A LEFT JOIN {$this->model->pre}channel B ON A.cid=B.id {$where}{$langwhere} ORDER BY A.hits DESC,A.sorter DESC, A.id DESC LIMIT {$limit}";
        $loop = $this->model->query($sql); //执行查询

        //计算数据总量
        $sql2 = "SELECT COUNT(*) FROM {$this->model->pre}content A LEFT JOIN {$this->model->pre}channel B ON A.cid = B.id {$where}";
        $count_menu = $this->model->query($sql2);
        $count = $count_menu[0]['COUNT(*)'];
        $this->assign('loop', $loop); 
        $this->assign('page', $this->page($url, $count, $listRows));
        }


        if($this->config['LANG_OPEN']==1){
        $this->display(__LANG__.'/'.$this->config['TPL_TEMPLATE_INDEX']);
        }else{
        $this->display($this->config['TPL_TEMPLATE_INDEX']);
        }


    }


}

?>